{% include 'head.html' %}








<body>





  <!-- 最为层容器 -->
  <div class="jd_container">
    <!-- 顶部 -->
    <div class="jd_header" style="height: 50px;background: #dce2ec;">

      <!--<span style="float: left;margin-left: -18%;margin-top: 15px;">货比三家</span>-->
      
      
      <div style="text-align:center;margin-top: 5%;">
        <span style="font-size: 18px;">设置个人信息</span>
      </div>
    </div>


    <div class="jd_nav" style="background-color: #fff;">

      <div style="margin-top: 25%;text-align:center;">


    <div class="page-header">
        <h4>1. 设置头像</h4>
        <form id="formdatas">
            <div class="form-group" id="uploadForm" enctype='multipart/form-data'>
                <div class="fileinput fileinput-new" data-provides="fileinput"  id="exampleInputUpload">
                    <div class="fileinput-new thumbnail" style="width: 200px;height: auto;max-height:150px;">
                        <img id='picImg' style="width: 100%;height: auto;max-height: 140px;" src="http://hbsj.xyz/h5/noimage.png" alt="" />
                    </div>
                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
                    <div>
                        <span class="btn btn-primary btn-file" style="width: 100%;">
                            <span class="fileinput-new" >点击此处选择设置头像</span>
                            <span class="fileinput-exists">换一张</span>
                            <!--<input type="file" id="picID" accept="image/*" mutiple="mutiple" capture="camera" />-->
                            <input type="file" id="picID" accept="image/*" mutiple="mutiple" />
                        </span>
                        <a href="javascript:;" class="btn btn-warning fileinput-exists" data-dismiss="fileinput" style="width: 100%;">移除</a>
                    </div>
                </div>
            </div>


            <hr>
             <h4>2. 选择年龄段</h4>

              <select id="ages">
                <option value="1">18~30岁</option>
                <option value="2">30~45岁</option>
                <option value="3">0~18岁</option>
                <option value="4">45岁以上</option>
            </select>

        </form>
    </div>
   


      <a href="/" style="color: #000;"><h3 style="margin-left: 8%;margin-top: 20%;float: left;">跳过</h3></a>
  <a onclick="adduserinfo();" style="color: #000;"><h3 style="margin-right: 8%;margin-top: 20%;float: right;">下一步</h3></a>
    

  </div>

  

</div>
 
  
  <script type="text/javascript">



    function adduserinfo(){

      var formdata = new FormData($("#formdatas")[0]);

      var ages_val = $("#ages").val();
      //alert(ages_val);

      var headimg = $('#picID').get(0).files[0];
      //alert(headimg);
      console.log(headimg);
      
      formdata.append('headimg',headimg);
      formdata.append('ageval',ages_val);
      console.log(formdata);

      if(headimg != undefined){
        //post_api_ajax3(formdata,"setuserinfoapi",setnamego_show);
        $.ajax({
            url: api_path+"/setuserinfoapi",
            type: 'post',
            cache: false,
            processData:false,
            contentType:false,
            data: formdata,
            dataType:'JSON',
            success:function (datas) {
                //alert(datas);
                if(datas == 0){

                    webToast("上传的头像格式错误！","middle",3000);
                }
                else if(datas == 1){
                  webToast("设置成功","middle",2000);
                  window.location.href="/";
                }
                else if(datas == 2){

                webToast("异常请求，开发不易请勿破坏","middle",2000);
                window.location.href="/";
                }

            }
        });
      }
      else{
        alert("请添加头像");
      }

      


    }

    function setnamego_show(datas){
      if(datas == 0){

                webToast("昵称已存在，请更换！","middle",3000);
             }
             if(datas == 1){

                webToast("设置成功","middle",2000);
                window.location.href="/";
             }
             if(datas == 2){

                webToast("异常请求，开发不易请勿破坏","middle",2000);
                window.location.href="/";
             }
             if(datas == 3){

                //webToast("登录成功-需要填写个人信息","middle",2000);
                popTipShow.alert('昵称非法','1.昵称不能含有非法字符；2.不能含有敏感词汇；3.长度范围在1个字符到10个字符。', ['确认'],
                function(e){
                  //callback 处理按钮事件     
                  var button = $(e.target).attr('class');
                  if(button == 'ok'){
                  //按下确定按钮执行的操作
                  //todo ....

                  window.location.href="/setname";

                  this.hide();

                  } 
                }
              );
             }
    }

    
    function setnamego() {
      
      var namedata = $("#nameval").val();

      if(namedata != ""){
        //webToast(namedata,"middle",2000);
        var datas = {
                  "names":namedata
                  
                }
                post_api_ajax3(datas,"setnameapi",setnamego_show);
                }
      
      else{
        webToast("昵称不能为空","middle",2000);
      }

    }




  </script>
   
 

    <!-- 京东内容区域 -->
    <div class="jd_mian" id="container">
      <div class="main_content" style="background-color: #edf4ff;">
        
        
        


      
        
        



        



      </div>
    </div>


    

  </div>

</body>


{% include 'js.html' %}

</html>




